/**
 * 
 */
package cn.com.xcj.dao;

import org.hibernate.Session;

import cn.com.xcj.dto.User;

/**
 * @author xcj
 *
 */
public class UserDao implements UserOperInterface{
	
	@Override
	public String insertUser(User user) {
		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
		session.beginTransaction();
		
		session.save(user);
		session.getTransaction().commit();
		
		return null;
	}
	@Override
	public String deletUser(int operatorID) {
		User user = new User();
		user.setOperatorID(operatorID);
		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
		session.beginTransaction();
		
		session.delete(user);
		session.getTransaction().commit();
		
		return null;
	}
	@Override
	public String updateUser(User user) {
		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
		session.beginTransaction();
		
		session.update(user);
		session.getTransaction().commit();
		
		return null;
	}
	@Override
	public User getUser(int userID) {
		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
		session.getTransaction();
		@SuppressWarnings("rawtypes")
		Class clazz = User.class;
		User user = (User)session.get(clazz,userID);
		
		return user;
	}
	
	
}
